// @ts-ignore
import { getCurrentInstance } from 'vue'


export const rpx2px = (rpxNum: number)=>{
    // @ts-ignore
    return uni.rpx2px?.(rpxNum) || uni.upx2px?.(rpxNum) ;
}


export const getElementStyle = (elementSelector: string, callBack: Function)=>{
    const { proxy } = getCurrentInstance()
    // @ts-ignore
    const query = uni.createSelectorQuery().in(proxy)
    query.select(elementSelector).boundingClientRect(data => {
        callBack(data)
    }).exec()
}

export const globalEventListen = (eventName:string, callback: Function) => {
    // @ts-ignore
    uni.$on(eventName, callback)
}
export const globalEventPublish = (eventName:string, event: any) => {
    // @ts-ignore
    uni.$emit(eventName,event)
}